<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no"
          name="viewport">
    <title>商品分类</title>
    <!-- Favicon and Touch Icons -->
    <link href="common/favicon.png" rel="shortcut icon" type="image/png">
    <link rel="stylesheet" href="background/modules/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="background/modules/ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="background/modules/fontawesome/web-fonts-with-css/css/fontawesome-all.min.css">

    <link rel="stylesheet" href="background/modules/summernote/summernote-lite.css">
    <link rel="stylesheet" href="background/modules/flag-icon-css/css/flag-icon.min.css">
    <link rel="stylesheet" href="background/css/style.css">
    <link rel="stylesheet" href="common/css/xtiper.css">
    <link rel="stylesheet" href="common/css/sweetalert.css">
    <link rel="stylesheet" href="common/datatable/dataTables.bootstrap4.min.css"/>
</head>

<body>
<div id="app">
    <div class="main-wrapper">
        <div class="navbar-bg"></div>
        <div th:replace="common/background-common::navbar(currUri='classify-manage')"></div>
        <div th:replace="common/background-common::sidebar(currUri='classify-manage')"></div>

        <div class="main-content">
            <section class="section">
                <h1 class="section-header">
                    <div>商品分类 <i class="ion ion-ios-color-filter"></i></div>
                </h1>
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12">
                        <div class="card mb-3">
                            <div class="card-body row">
                                <div class="col-12 custom-control-inline">
                                    <input type="text" class="form-control" id="newClassify" placeholder="请输入新增的商品分类名称 ..." >
                                    <button class="btn btn-success" onclick="addClassify()"><i class="fa fa-plus"> 新增</i></button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12">
                        <div class="card mb-3">
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table id="example1" class="table table-bordered table-hover display" style="text-align: center">
                                        <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>分类名称</th>
                                            <th>商品数</th>
                                            <th>创建时间</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody style="font-size: 13px">
                                            <tr th:each="classify:${classifies}">
                                                <td>
                                                    <span class="form-control" style="text-align: center"  th:text="${'#'+ classify.id}"></span>
                                                </td>
                                                <td>
                                                    <input th:onchange="updateClassify([[${classify.id}]])" th:id="${'classify'+classify.id}" class="form-control" style="text-align: center" type="text" th:value="${classify.name}">
                                                </td>
                                                <td>
                                                    <span class="form-control" style="text-align: center"  th:text="${classify.count + '（件）'}"></span>
                                                </td>
                                                <td>
                                                    <span class="form-control" style="text-align: center"  th:text="${#dates.format(classify.createTime,'yyyy-MM-dd HH:ss')}"></span>
                                                </td>
                                                <td>
                                                    <button th:if="${classify.count > 0}" type="button" class="btn btn-warning" data-toggle="tooltip" data-placement="top" title="" data-original-title=" 当前分类下已存在商品，无法删除！">
                                                        <i class="ion ion-information-circled"></i> 无法删除
                                                    </button>
                                                    <button th:if="${classify.count == 0}" th:onclick="deleteClassify([[${classify.id}]])" class="btn btn-danger"><i class="ion ion-trash-b"></i> 点击删除</button>
                                                </td>
                                            </tr>
                                        </tbody>
                                        <thead>
                                        </thead>
                                    </table>
                                </div>

                            </div>
                        </div><!-- end card-->
                    </div>
                </div>
            </section>
        </div>

        <div th:replace="common/background-common::footer"></div>
    </div>
</div>

<script src="background/modules/jquery.min.js"></script>
<script src="common/js/xtiper.min.js"></script>
<script src="common/js/sweetalert.js"></script>
<script src="common/js/custom.js"></script>
<script src="common/datatable/jquery.dataTables.min.js"></script>
<script src="common/datatable/dataTables.bootstrap4.min.js"></script>
<script src="background/modules/popper.js"></script>
<script src="background/modules/tooltip.js"></script>
<script src="background/modules/bootstrap/js/bootstrap.min.js"></script>
<script src="background/modules/nicescroll/jquery.nicescroll.min.js"></script>
<script src="background/modules/scroll-up-bar/dist/scroll-up-bar.min.js"></script>
<script src="background/js/sa-functions.js"></script>

<script src="background/modules/chart.min.js"></script>
<script src="background/modules/summernote/summernote-lite.js"></script>

<script src="background/js/scripts.js"></script>

<script>
    // START CODE FOR BASIC DATA TABLE
    $(document).ready(function() {
        $('#example1').DataTable({
            language: {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项结果",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "表中数据为空",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                }
            },
            "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 1,3,4 ]}],
        });
    });

</script>
</body>
</html>
